Learn to Code HTML & CSS 12
Lesson 12: Writing Your Best Code
Contents
- Be well organized, so that it is easy to read, edit, and maintain
- Be modular and flexible, allowing us to reuse code and patterns as necessary
- Look as if one person wrote it, even if several people contributed
HTML Coding Practices
- Write Standards-Compliant Markup
- Make Use of Semantic Elements
- Use the Proper Document Structure
- Keep the Syntax Organized
- Use Practical ID & Class Values
- Use the Alternative Text Attribute on Images
- Separate Content from Style
- Avoid a Case of “Divitis”
- Continually Refactor Code
CSS Coding Practices
- Organize Code with Comments
- Write CSS Using Multiple Lines & Spaces
- Use Proper Class Names
- Build Proficient Selectors
- Use Specific Classes When Necessary
- Use Shorthand Properties & Values
- Use Shorthand Hexadecimal Color Values
- Drop Units from Zero Values
- Group & Align Vendor Prefixes
- Modularize Styles for Reuse